<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>设置>设置人员和角色</title>
<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
<%@include file="../../../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath}/public.css" />
<link rel="stylesheet" type="text/css" href="${csspath}/style_l.css" />
<script src="${jspath}/jquery/jquery-1.4.4.js" type="text/javascript"></script>
<script type="text/javascript" src="${jspath}/public.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath}/jquery.alerts.css" />
<script type="text/javascript">
var selected = new Array();//曾经选择过的列表
var maxIndex = 0;
$(function() {

	$("#table_one tr").each(function() {
		$(this).children("td:last").hide();
	});

	$("#select_all_one").click(function() {
		$("input[name='check_one']:checkbox").attr("checked",$("input[name='check_one']:checkbox").attr("checked"));
	});
	
	$("#select_all_two").click(function() {
		$("input[name='check_two']:checkbox").attr("checked",$("input[name='check_two']:checkbox").attr("checked"));
	});

	$("#leftToright").click(function() {
		$("#select_all_one").attr("checked",false);
		var $table_two = $("#table_two tbody");
		for (i=0 ; i<selected.length; i++){
			$sele = $("#"+selected[i]);
			if ($sele.attr("checked")==true && $sele.attr("name")=="check_one"){
				var $tr = $sele.parent().parent();
				$sele.attr("name", "check_two");
				$table_two.append($tr);
				$sele.attr("checked",true);
				$tr.children("td:last").show();
			}
		}
		
		var $checked = $("input[name='check_one']:checkbox:checked");//第一次选择
		$checked.each(function(i){
			var $input = $(this);
			var $tr = $input.parent().parent();
			$input.attr("name", "check_two");
			$table_two.append($tr);
			$input.attr("checked",true);
			$tr.children("td:last").show();
			selected[maxIndex++] = $input.attr("id");
		});
	});

	$("#rightToleft").click(function() {
		$("#select_all_two").attr("checked",false);
		var $table_one = $("#table_one tbody");
		for (i=0 ; i<selected.length; i++){
			$sele = $("#"+selected[i]);
			if ($sele.attr("checked")==true && $sele.attr("name")=="check_two"){
				var $tr = $sele.parent().parent();
				$sele.attr("name", "check_one");
				$table_one.append($tr);
				$tr.children("td:last").hide();
				$sele.attr("checked", false);
			}
		}
		
		var $checked = $("input[name='check_two']:checkbox:checked");//第一次选择
		$checked.each(function(i){
			var $input = $(this);
			var $tr = $input.parent().parent();
			$input.attr("name", "check_one");
			$table_one.append($tr);
			$tr.children("td:last").hide();
			$input.attr("checked", false);
			selected[maxIndex++] = $input.attr("id");
		});
	});
	
});

function doCancel() {
	window.history.back();
}

function doSubmit() {
	$("input[name='check_two']:checkbox").attr("checked", "true");
	$("#select_all_two").attr("checked",false);
	for (i=0 ; i<selected.length; i++){
		$sele = $("#"+selected[i]);
		if ($sele.attr("name")=="check_two"){
			$sele.attr("checked", true);
		}
	}
	$("#search_form").attr("action", "${webcontext}/userPerm/userAndRole/updateauthorizeduser");
	$("#search_form").submit();
}

</script>
</head>

<body>

	<!-- content -->
	<div id="content">
		<!-- wrap -->
		<div id="wrap">

			<!-- breadcrumb -->
			<div id="breadcrumb">
            <div class="left">
				<span>人员角色关系维护（特殊授权）详情</span></div>
                <div class="right">
                    <a href="javascript: window.history.back();" class="back">返回</a>
            </div>
			</div>
			<!-- /breadcrumb -->

			<form name="search_form" id="search_form" action="updateauthorizeduser" method="post">
			<input type="hidden" name="userId" value="${userId}" />
			<!-- info_div -->
			<div class="info_div">
				<div class="title">
					<p class="min" title="点击展开/隐藏详细信息">基本资料</p>
				</div>
                <div>
				<table class="info_tab">
					<tr>
<!--                    	<td align="center" width="140" valign="middle" rowspan="14">-->
<!--							<img src="${imagepath}/pictures_l/people.jpg"/>-->
<!--						</td>-->
                    </tr>
                    <tr>
                      <td class="label">经销商代码：</td>
                      <td>${authDto.dealerCode}</td>
                      <td class="label">经销商简称：</td>
                      <td>${authDto.dealerAbbreName}</td>
                      <td class="label">人员类型：</td>
                      <td>${authDto.isSGMText}</td>
                    </tr>
                    <tr>
                      <td class="label">员工编号：</td>
                      <td>${authDto.employeeCode}</td>
                      <td class="label">用户ID：</td>
                      <td>${authDto.userCode}</td>
                      <core:if test="${authDto.userGroupCodes == 'saleconsultant'}">
                      <td class="label">销售顾问<br />
                       	 等级：
                      </td>
                      <td>${authDto.saleConsultLevel}</td>
                      </core:if>
                    </tr>
                    
				 <tr>
					  <td colspan="8" class="spliterInput_Line">
					    <img src="${imagepath}/pictures_l/spliterInput_line_03.gif" />
					  </td>
				  </tr>  
				                  
                    <tr>
                      <td height="31" class="label">员工姓名：</td>
                      <td>${authDto.employeeName}</td>
                      <td class="label">性别：</td>
                      <td>${authDto.genderName}</td>
                      <td class="label">手机：</td>
                      <td>${authDto.mobilePhone}</td>
                    </tr>
                    <tr>
                      <td class="label">可导出数据：</td>
                      <td>
					  	<core:if test="${authDto.exportData == 1}">可导出</core:if>
					  	<core:if test="${authDto.exportData == 2}">不可导出</core:if>
					  </td>
                      <td class="label">电子邮件：</td>
                      <td colspan="3">${authDto.email}</td>
                    </tr>
                    <tr>
                      <td class="label">证件类型：</td>
                      <td>${authDto.certificateName}</td>
                      <td class="label">证件号码：</td>
                      <td>${authDto.certificateCode}</td>
                      <td class="label">婚姻状况：</td>
                      <td>${authDto.marriageStatus}</td>
                    </tr>
                    <tr>
                      <td class="label">籍贯：</td>
                      <td>${authDto.birthPlace}</td>
                      <td class="label">生日：</td>
                      <td><fmt:formatDate value="${authDto.birthDate}" pattern="yyyy-MM-dd"/></td>
                      <td class="label">学历：</td>
                      <td>${authDto.educationText}</td>
                    </tr>
                    <tr>
                       <td class="label">住址：</td>
                       <td colspan="3">${authDto.address}</td>
                       <td class="label">就业状态：</td>
                       <td>${authDto.employmentStatus}</td>
                    </tr>
                    
                    <tr>
					  <td colspan="8" class="spliterInput_Line">
					    <img src="${imagepath}/pictures_l/spliterInput_line_03.gif" />
					  </td>
				  </tr>  
					
                    <tr>
                       <td class="label"><p>目前岗位入职</p>
                       <p>日期：</p></td>
                       <td><fmt:formatDate value="${authDto.onboardDate}" pattern="yyyy-MM-dd"/></td>
                       <td class="label"><p>首服务品牌</p>
                       <p>日期：</p></td>
                       <td><fmt:formatDate value="${authDto.brandFirstServiceDate}" pattern="yyyy-MM-dd"/></td>
                       <td class="label"><p>是否受过品牌</p>
                       <p>培训：</p></td>
                       <td>
                       	<core:if test="${authDto.isBrandTraining == 1}">是</core:if>
                       	<core:if test="${authDto.isBrandTraining == 2}">无</core:if>
					  </td>
                    </tr>
                    <tr>
                       <td class="label"><p>通过岗位培训</p>
                        <p>日期：</p></td>
                       <td><fmt:formatDate value="${authDto.passTrainingDate}" pattern="yyyy-MM-dd"/></td>
                       <td class="label">是否有驾照：</td>
                       <td>
					   	<core:if test="${authDto.hasDriverLicense == 1}">是</core:if>
                       	<core:if test="${authDto.hasDriverLicense == 2}">无</core:if>
					   </td>
                       <td class="label">&nbsp;</td>
                       <td>&nbsp;</td>
                    </tr>
                    
                  </table>
                </div>
			</div>
			<!-- /info_div -->
            <div class="spliter h_5"></div>
            
			<!-- /info_div -->

        <div class="spliter h_10"></div>
            
        <!-- info_div -->
			<div class="info_div">
            	<div class="title"><p class="min" title="点击展开/隐藏详细信息">
            	未赋予角色
            	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            	已赋予角色
            	</p></div>
                <div>
                   <!-- <div class="page_div">
                    </div>-->
                    <table class="info_tab">
                	<tr>
                    	<td class="td_tab">
                            <table class="data_tab" id="table_one">
                                <tr>
                                  <th><input type="checkbox" name="check_one" value="-1" id="select_all_one" /></th>
                                  <th class="w_20">角色代码</th>
                                  <th class="w_20">角色名称</th>
                                </tr>
                                <core:forEach items="${allRoleList}" var="allRole" varStatus="ind">
                                <tr>
                                  <td class="align_m"><input type="checkbox" id="left${ind.index}" name="check_one" value="${allRole.id}" class="select_one" /></td>
                                  <td>${allRole.roleCode}</td>
                                  <td>${allRole.roleName}</td>
                                  <td></td>
                                </tr>
                                </core:forEach>                                
                            </table>
                  </td>
                        
                        <td class="td_spliter" style="width:30px; text-align:center;"> 
                        	<input type="button" value="&gt;&gt;" id="leftToright" />
                            <input type="button" value="&lt;&lt;" id="rightToleft" />
                      </td>
                        
                        <td class="td_tab">
                          <table class="data_tab" id="table_two">
                            <tr>
                              <th><input type="checkbox" name="check_two" value="-1" id="select_all_two" /></th>
                              <th class="w_20">角色代码</th>
                              <th class="w_20">角色名称</th>
                              <th class="w_20">岗位默认角色</th>
                            </tr>
                            <core:forEach items="${selectedList}" var="selected" varStatus="ind">
                            <tr>
                              <td class="align_m"><input type="checkbox" id="right${ind.index}" name="check_two" value="${selected.role.id},${selected.isDefaultRole}" class="select_one" /></td>
                              <td>${selected.role.roleCode}</td>
                              <td>${selected.role.roleName}</td>
                              <td>
                              	<core:if test="${selected.isDefaultRole == 1}">是</core:if>
                              </td>
                            </tr>
                            </core:forEach>
                          </table>
                      </td>
                      </tr>
                      </table>
                </div>
			</div>
			
			<div class="spliter h_5"></div>
            
        	<div class="spliter h_5"></div>
        	
			<div class="btn_div">
            	<input type="button" class="btn" value="确认" onClick="doSubmit();" id="save_add_gw"/>
                <input type="button" class="btn" value="取消" onClick="doCancel();" id="cancel_add_gw"/>
            </div>
			<!-- /info_div -->
        </form>
		<!-- /wrap -->
	</div>
	<!-- /content -->

</body>
</html>